找传奇、传世资源到传世资源站!

asp.net 生成二维码 示例源码

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

可生成任意信息的二维码
from clipboard using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using QuickMark;using System.IO;using System.Drawing.Imaging;using System.Runtime.InteropServices;using ThoughtWorks.QRCode.Codec;using ThoughtWorks.QRCode.Codec.Data;using ThoughtWorks.QRCode.Codec.Util;using System.Drawing;using System.Text;using System.Net;namespace QRCode{ public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string str = TextBox1.Text; string path = System.Web.HttpContext.Current.Server.MapPath("images"); string file = path "\\code.png"; if (ToQRCode(str, file)) { Image1.ImageUrl = "images/code.png"; Label1.Text = "生成成功"; } else Label1.Text = "生成失败"; } private bool ToQRCode(string str, string filename) { QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; qrCodeEncoder.QRCodeVersion = 7; qrCodeEncoder.QRCodeScale = 4; //生成图像 Bitmap image = qrCodeEncoder.Encode(str, Encoding.Default); //将image保存到filename image.Save(filename); return true; } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复